#ifndef ENTIMEDTHREAD_H
#define ENTIMEDTHREAD_H

#include <QTimer>
#include <QThread>
#include <QSemaphore>
#include <QApplication>
#include <lockedsemaphore.h>

/* EnTimedThread is a parent class that is meant to be inherited to create quick and easy timed threads that will
   self terminate upon the closure of the program. Simply inherit and override the update() method.

   Args:
   parent: QObject parent!
   fps: frames per second you would like the thread to recur at
   s: The QSemaphore that we will signal to finish the program
   a: the QApplication that is shutting down
   */
class EnTimedThread : public QThread
{
    Q_OBJECT

public:

    EnTimedThread( QObject* parent, int fps, LockedSemaphore* s, QApplication& a );
    EnTimedThread( int fps, LockedSemaphore* s, QApplication& a );
    void run();
    float getWaitTime();

public slots:
    void handleQuit();

private slots:
    void update();

private:
    QTimer timer;
    LockedSemaphore* waitForCleanUp;
    float waitTime;

};

#endif // ENTIMEDTHREAD_H
